//
//  KCTDeviceCell.swift
//  BLEManagerSwiftDemo
//
//  Created by Qinsz on 2019/5/22.
//  Copyright © 2019年 Qinsz. All rights reserved.
//

import UIKit

class KCTDeviceCell: UITableViewCell {

    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var idLabel: UILabel!
    
    @IBOutlet weak var RSSILabel: UILabel!
    
    
//    var peripheral : KCTPeripheral?{
//        didSet{
//            //渲染UI
//            nameLabel.text = peripheral?.peripheral?.name
//            
//            var idStr :String?
//            if let count = peripheral?.macString?.count{
//                if count>0 {
//                    idStr = peripheral?.macString
//                }
//            }else{
//                idStr = peripheral?.peripheral?.identifier.uuidString
//            }
//            idLabel.text = idStr
//            
//            let rssi = peripheral?.RSSI?.intValue
//            
//            if let `rssi` = rssi {
//                RSSILabel.text = rssi.description
//            }else{
//                RSSILabel.text = nil
//            }
//        }
//    }
    
    var per:CBPeripheral?{
        didSet{
            //渲染UI
            nameLabel.text = per?.name
            
            var idStr :String?
            if let count = per?.macString?.count{
                if count>0 {
                    idStr = per!.macString!
                }
            }else{
                idStr = per?.identifier.uuidString
            }
            idLabel.text = idStr
            
            let rssi = per?.rssi?.intValue
            
            if let `rssi` = rssi {
                RSSILabel.text = rssi.description
            }else{
                RSSILabel.text = nil
            }
        }
    }
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
